//
//  MGBeginnerGuideManager.m
//  MortgageHelper
//
//  Created by zhangxiang on 16/12/14.
//  Copyright © 2016年 zhangxiang. All rights reserved.
//

#import "MGBeginnerGuideManager.h"


static MGBeginnerGuideManager *_guideManager=nil;

#define OnceGuideView @"OnceGuideView"


@implementation MGBeginnerGuideManager
+(MGBeginnerGuideManager *)sharemanager{
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _guideManager = [MGBeginnerGuideManager new];
       
    });
    return _guideManager;
    
}

// 新手引导

-(void)checkOnceGuideView:(UIViewController *)ViewController :(ToolEnumtype) type{
    NSArray *arr=nil;
    
    if (type==ToolConsultTheFiles) {
        arr=@[@"yindao_baogao",@"yindao_guohujia"];
    }else if (type==ToolTheTransferPrice){
        arr=@[@"yindao_baogao",@"yindao_chadang"];
    }else if (type==ToolFuturePrices){
        arr=@[@"yindao_baogao",@"yindao_shuifei"];
    }
    if (arr==nil) {
        return;
    }
    if (![USER_DEFAULT objectForKey:OnceGuideView]) {   //    ![USER_DEFAULT objectForKey:OnceGuideView]
        
        for (NSString *imagestring in arr) {
            
            UIButton *imageButton=[UIButton buttonWithType:UIButtonTypeSystem];
            imageButton.frame=KEY_WINDOW.bounds;
            
            [imageButton setBackgroundImage:[UIImage imageNamed:imagestring] forState:UIControlStateNormal];
            [imageButton addTarget:_guideManager action:@selector(remotargetView:) forControlEvents:UIControlEventTouchUpInside];
            
            if (ViewController) {
                
            }else{
                [KEY_WINDOW addSubview:imageButton];
            }
    
        }
    }else{
        
    }
    [USER_DEFAULT setObject:OnceGuideView forKey:OnceGuideView];
    [USER_DEFAULT synchronize];

}
-(void)remotargetView:(UIButton *)sender{
    
    [sender removeFromSuperview];
}



@end
